//
//  PKBaseViewController.m
//  AMomentApp
//
//  Created by lanou on 15/9/25.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "PKBaseViewController.h"

@interface PKBaseViewController ()

@end

@implementation PKBaseViewController

-(UIView *)topView
{
    if (!_topView) {
        _topView = [[UIView alloc]initWithFrame:CGRectMake(0, 20, SCREEN_WIDTH, 50)];
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(45, 0, 1, self.topView.bounds.size.height)];
        imageView.image = [UIImage imageNamed:@"essage"];
        [_topView addSubview:imageView];
        _topView.backgroundColor = [UIColor whiteColor];
        _leftButton = [UIButton buttonWithType:UIButtonTypeCustom];
        _leftButton.frame = CGRectMake(10, 13, 25, 25);
        [_leftButton setImage:[UIImage imageNamed:@"returnreturn.png"] forState:UIControlStateNormal];
        [_leftButton addTarget:self action:@selector(getBackToRootViewController:) forControlEvents:UIControlEventTouchUpInside];
        [_topView addSubview:_leftButton];
        UIImageView *bottomImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, self.topView.bounds.size.height-1, SCREEN_WIDTH, 1)];
        bottomImageView.backgroundColor = [UIColor colorWithWhite:0.667 alpha:0.210];
        bottomImageView.image = [UIImage imageNamed:@"line"];
        [_topView addSubview:bottomImageView];
        [_topView addSubview:self.titleLable];
#pragma mark - 周期(self.view是采取懒加载的方式 这样会使self.view提前调用ViewDidLoad方法)
        [self.view addSubview:_topView];
    }
    return _topView;
}

-(UILabel *)titleLable
{
    if (!_titleLable) {
        _titleLable = [[UILabel alloc]initWithFrame:CGRectMake(50, 10, 100, 30)];
    }
    return _titleLable;
}

- (void)getBackToRootViewController:(UIButton *)button
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    NSLog(@"%@",self.topView);
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
